<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
</head>
<body>
    <button>清理定时器</button>
</body>
<script>
    //定时器
    //1.延迟定时器
     var  timer=setTimeout(function(){
        console.log('时间到');
     } ,5000)
    //2.循环定时器
     var  time=setInterval(function(){
        console.log('我来了');
     } ,1000);
     document.querySelector('button')
     .addEventListener('click',function(){
         //清理定时器
         clearInterval(time)
     })
</script>
</html>